<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Mahasiswa extends CI_Controller 
{	
	function __construct()
	{
		parent::__construct();
		$this->load->model('model_mahasiswa');
	}

	function index()
	{
		$data['data']=$this->model_mahasiswa->tampilData();
		$this->load->view("mahasiswa_view",$data);
	}

	function tambah()
	{
		$data = array(
			'nim' => $this->input->post('nim'), 
			'nama' => $this->input->post('nama'), 
			'hp' => $this->input->post('hp')
		);
		$this->model_mahasiswa->tambah($data);
		redirect('master_data/data/1');
	}

	function edit()
	{
		$nim = $this->uri->segment(3);
		$data['data'] = $this->model_mahasiswa->per_id($nim);
		$this->load->view('mahasiswa_view',$data);
	}

	function update()
	{
		$nim = $this->input->post('nim');
		$data = array(			
			'nama' => $this->input->post('nama'), 
			'hp' => $this->input->post('hp')
		);
		$this->model_mahasiswa->update($nim,$data);
		//redirect('master_data/data/1');
		redirect('mahasiswa');
	}

	function hapus()
	{
		$nim = $this->uri->segment(3);
		$this->model_mahasiswa->hapus($nim);		
		//redirect('master_data/data/1');
		redirect('mahasiswa');
	}
}

?>